<div class="box box-solid no-margin box-show">
    <div class="box-body">
        <h4>基本信息</h4>
        <div class="box-body table-responsive no-padding">
            <table class="table">
                <thead>
                <tr>
                    <th width="10%">发货单ID</th>
                    <th>销售员</th>
                    <th>发货账号</th>
                    <th>发货站点</th>
                    <th>发货国家</th>
                    <th>发货时间</th>
                    <th>状态</th>
                    <th>物流状态</th>
                    <th>ReferenceID</th>
                    <th>仓库编码</th>
                    <th width="15%">收货地址</th>
                    <th>物流单号</th>
                    <th>到货时间</th>
                    <th>运费</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{{ $delivery->delivery_no }}</td>
                    <td>{{ \App\Util\User::getUsernameById($delivery->seller_id) }}</td>
                    <td>{{ $delivery->account->account ?? '' }}</td>
                    <td>{{ $delivery->area->area ?? '' }}</td>
                    <td>{{ $delivery->country->country ?? '' }}</td>
                    <td>{{ $delivery->delivered_at ?? '' }}</td>
                    <td>{{ $delivery->status < 7 ? \App\Models\Delivery\FBADelivery::$_status[$delivery->status] : '' }}</td>
                    <td>{{ $delivery->logistics_status ? \App\Models\Delivery\FBADelivery::$_logisticsStatus[$delivery->logistics_status] : '' }}</td>
                    <td>
                        <a class="grid-editable-reference_id" href="#" data-type="text" data-pk="{{ $id }}" data-url="{{ '/xqc/delivery/fba/'.$id }}" data-value="{{ $delivery->reference_id }}">{{ $delivery->reference_id }}</a>
                    </td>
                    @if($delivery->status != 6)
                        <td>
                            <a class="grid-editable-d_address_code" href="#" data-type="text" data-pk="{{ $id }}" data-url="{{ '/xqc/delivery/fba/'.$id }}" data-value="{{ $delivery->d_address_code }}">{{ $delivery->d_address_code }}</a>
                        </td>
                        <td>
                            <a class="grid-editable-d_address" href="#" data-type="textarea" data-pk="{{ $id }}" data-url="{{ '/xqc/delivery/fba/'.$id }}" data-value="{{ $delivery->d_address }}">{{ $delivery->d_address }}</a>
                        </td>
                    @else
                        <td>{{ $delivery->d_address_code ?? '' }}</td>
                        <td>{{ $delivery->d_address ?? '' }}</td>
                    @endif
                    <td>{{ $delivery->logistics->tracking_no ?? '' }}</td>
                    <td>{{ $delivery->logistics->arrived_at ?? '' }}</td>
                    <td>{{ $delivery->logistics->shipping_fee ?? '' }}</td>
                </tr>
                </tbody>
            </table>
            <table class="table">
                <thead>
                <tr>
                    <th>货件追踪编码</th>
                    <th>备注</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>
                        <a class="grid-editable-track_no" href="#" data-type="text" data-pk="{{ $id }}" data-url="{{ '/xqc/delivery/fba/'.$id }}" data-value="{{ $delivery->track_no }}">{{ $delivery->track_no }}</a>
                    </td>
                    <td>
                        <a class="grid-editable-remarks" href="#" data-type="textarea" data-pk="{{ $id }}" data-url="{{ '/xqc/delivery/fba/'.$id }}" data-value="{{ $delivery->remarks }}">{{ $delivery->remarks }}</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<div class="box box-solid no-margin box-show">
    <div class="box-body">
        <h4>产品信息</h4>
        <div class="box-body table-responsive no-padding">
            <table class="table">
                <thead>
                <tr>
                    <th>SKU总数</th>
                    <th>产品总件数</th>
                    <th>实发总件数</th>
                    <th>发货箱数</th>
                    <th>发货公斤数</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{{ $delivery->total_sku }}</td>
                    <td>{{ $delivery->total_unit }}</td>
                    <td>{{ $delivery->ship_total_unit }}</td>
                    <td>
                        @if($delivery->status == 3)
                            <a class="grid-editable-total_box" href="#" data-type="text" data-pk="{{ $id }}" data-url="{{ '/xqc/delivery/fba/'.$id }}" data-value="{{ $delivery->total_box }}">{{ $delivery->total_box }}</a>
                        @else
                            {{ $delivery->total_box }}
                        @endif
                    </td>
                    <td>{{ $delivery->logistics->total_weight ?? '' }}</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script language="JavaScript" type="text/javascript">
    $(function () {
        var _editableRefresh = function (name) {
            $('.grid-editable-'+name).editable({"emptytext":"<i class=\"fa fa-pencil\"><\/i>","showbuttons":false,"mode":"inline","name":name,
                success: function(response, newValue) {
                    if (typeof response === 'object') {
                        if (response.status) {
                            toastr.success('提交成功 !');
                            $.pjax.reload("#fba-form");
                        } else {
                            swal(response.message, '', 'error');
                        }
                    }
                }
            });
        };

        var _editable = function (name) {
            $('.grid-editable-'+name).editable({"emptytext":"<i class=\"fa fa-pencil\"><\/i>","showbuttons":false,"mode":"inline","name":name,
                success: function(response, newValue) {
                    if (typeof response === 'object') {
                        if (response.status) {
                            toastr.success('提交成功 !');
                        } else {
                            swal(response.message, '', 'error');
                        }
                    }
                }
            });
        };

        var _editableWithoutResult = function (name) {
            $('.grid-editable-'+name).editable({"emptytext":"<i class=\"fa fa-pencil\"><\/i>","name":name});
        };
        _editableWithoutResult('reference_id');
        _editableWithoutResult('d_address_code');
        _editableWithoutResult('d_address');
        _editable('total_box');
        _editableWithoutResult('remarks');
        _editableWithoutResult('track_no');
    });
</script>
